<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  let a = {
    value: 1
  }
  function getValue(name, age) {
    console.log(name)
    console.log(age)
    console.log(this.value)
  }

  // 实现一个call
  Function.prototype.myCall = function (value) {
    const context = value || window
    context.fn = this
    const args = [...arguments].slice(1)
    const result = context.fn(...args)
    console.log(arguments, 'result')
    delete context.fn
    return result
  }

  getValue(1, 2)
  // 把getValue的Value的this指向a
  getValue.myCall(a, 'peo', '24')
</script>
</body>
</html>
